#include<bits/stdc++.h>
using namespace std;
struct car{
    double d,v,a;
    int b,e;
};
car c[100005];
int T,n,m,ans,num,add;
double L,V;
double p[100005];
double overPos;
vector< set<int> > v;
set<int> s;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    for (int t=1;t<=T;t++){
        scanf("%d %d %lf %lf",&n,&m,&L,&V);
        for (int i=1;i<=n;i++){
            scanf("%lf %lf %lf",&c[i].d,&c[i].v,&c[i].a);
        }
        for (int i=1;i<=m;i++){
            scanf("%lf",&p[i]);
        }
        sort(p+1,p+m+1);
        p[m+1]=L+1.0;
        ans=0;
        num=2e9;
        v.clear();
        v.resize(m+5);
        for (int i=0;i<v.size();i++){
            v[i].clear();
        }
        for (int i=1;i<=n;i++){
            c[i].e=m+1;
            if (c[i].a == 0){
                if (c[i].v > V){
                    overPos=0.0;
                    c[i].b=lower_bound(p+1,p+m+1,c[i].d)-p;
                }
                else {
                    overPos=L+1.0;
                    c[i].b=m+1;
                }
            }
            else if (c[i].a > 0){
                if (c[i].v > V){
                    overPos=0.0;
                    c[i].b=lower_bound(p+1,p+m+1,c[i].d)-p;
                }
                else {
                    overPos=c[i].d+(V*V-c[i].v*c[i].v)/(2.0*c[i].a);
                    if (overPos > L){
                        overPos=L+1.0;
                        c[i].b=m+1;
                    }
                    else {
                        c[i].b=lower_bound(p+1,p+m+1,overPos)-p;
                    }
                }
            }
            else {
                if (c[i].v > V){
                    c[i].b=lower_bound(p+1,p+m+1,c[i].d)-p;
                    overPos=c[i].d+(V*V-c[i].v*c[i].v)/(2.0*c[i].a);
                    if (overPos > L){
                        c[i].e=m+1;
                    }
                    else {
                        c[i].e=upper_bound(p+1,p+m+1,overPos)-p-1;
                    }
                }
                else {
                    overPos=L+1;
                    c[i].b=m+1;
                }
            }
            //printf("%d:%d %d %lf\n",i,c[i].b,c[i].e,overPos);
            if (c[i].e >= c[i].b && c[i].b < m+1){// be recorded
                ans+=1;
                for (int j=c[i].b;j<=c[i].e;j++){
                    v[j].insert(i);
                }
            }
        }
        for (long long i=0;i<(1<<m);i++){
            s.clear();
            add=0;
            for (int j=0;j<m;j++){
                if ((i>>j)&1){
                    for (auto &&k:v[j+1]){
                        s.insert(k);
                    }
                    add++;
                }
            }
            //for (auto &&j:s){
            //    printf("%d ",j);
            //}
            if (s.size() == ans){
                num=min(num,add);
            }
        }
        printf("%d %d\n",ans,m-num);
    }
    return 0;
}
